using System;
using System.Collections.Generic;
using System.Text;

using System.Xml;
using ZoneFiveSoftware.Common.Visuals.Fitness;

namespace PolarImport
{
    /// <summary>
    /// 
    /// </summary>
    class Plugin : IPlugin 
    {
        #region Private members

        private static Plugin instance = null;

#if (DEBUG)
        private static string debugInfo = "PolarImport Plugin Debug information: " + Environment.NewLine;
#endif

        private static IApplication application;

        private static readonly Guid pluginID = new Guid("{a437d4a6-713b-43aa-b1d9-d3595f883b6e}");

        #endregion

        /// <summary>
        /// Initializes a new instance of the <see cref="Plugin"/> class.
        /// </summary>
        public Plugin()
        {
            instance = this;
        }
        
        #region IPlugin Member

        /// <summary>
        /// Return the unique identifier for this plugin for storing options, versioning, etc.
        /// </summary>
        /// <value></value>
        public Guid Id
        {
            get 
            { 
                return pluginID; 
            }
        }

        /// <summary>
        /// Set the application context that the plugin can use to drive the application.
        /// </summary>
        /// <value></value>
        public IApplication Application
        {
            get 
            { 
                return application; 
            }

            set 
            { 
                application = value; 
            }
        }

        /// <summary>
        /// Return the display name of the plugin.
        /// </summary>
        /// <value></value>
        public string Name
        {
            get 
            { 
                return "Polar Import"; 
            }
        }

        /// <summary>
        /// Return the display version of the plugin.
        /// </summary>
        /// <value></value>
        public string Version
        {
            get 
            { 
                return GetType().Assembly.GetName().Version.ToString(3); 
            }
        }

        /// <summary>
        /// Read any plugin-specific data from the user options xml data store.
        /// </summary>
        /// <param name="xmlDoc"></param>
        /// <param name="nsmgr"></param>
        /// <param name="pluginNode"></param>
        public void ReadOptions(XmlDocument xmlDoc, XmlNamespaceManager nsmgr, XmlElement pluginNode)
        {
        }

        /// <summary>
        /// Write any plugin-specific data to the user options xml data store.
        /// </summary>
        /// <param name="xmlDoc"></param>
        /// <param name="pluginNode"></param>
        public void WriteOptions(XmlDocument xmlDoc, XmlElement pluginNode)
        {
        }

        #endregion

        /// <summary>
        /// Gets the instance.
        /// </summary>
        /// <value>The instance.</value>
        public static Plugin Instance
        {
            get { return instance; }
        }

#if (DEBUG)
        /// <summary>
        /// A window used to display debug messages
        /// </summary>
        public static DebugWindow debugWindow;

        /// <summary>
        /// Adds a debug info.
        /// </summary>
        /// <param name="info">The info.</param>
        public static void AddDebugInfo(string info)
        {
            if (info != null)
            {
                debugInfo += info + Environment.NewLine;
            }
        }

        /// <summary>
        /// Gets the debug infos.
        /// </summary>
        /// <value>The debug infos.</value>
        public static string DebugInfos
        {
            get
            {
                return debugInfo;
            }
        }
#endif

    }
}
